<h4>Create Salary</h4>

<?= form_open('founder/salary/create_salary')?>
<table width="100%">
  <tr>
    <td width="20%">For</td>
    <td width="40%">
    <select name="user">
    <option value="">-- Select User -- </option>
    <?php foreach($users as $user) {?>
    <option value="<?= $user->id?>" > <?= $user->username?> </option>
    <?php }?>
    </select>
    </td>
    <td width="40%" class="text-error"><?= form_error('user')?></td>
  </tr>
  <tr>
    <td>Total Payable Salary  <small class="text-info">( Per month)</small></td>
    <td><div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input class="salary span12" id="prependedInput" type="text" placeholder="in ruppes" name="salary" value="<?=set_value('salary')?>">
</div></td>
    <td class="text-error">
    <?= form_error('salary')?>
    </td>
  </tr>
  <tr>
    <td>Per day <small class="muted">( Total Salary / 25 )</small></td>
    <td><div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input class="per_day span4" id="prependedInput" type="text" placeholder="" name="per_day_salary"  value="<?=set_value('per_day_salary')?>" readonly="readonly" ></td>
    <td class="text-error"> <?= form_error('per_day_salary')?>   </td>
  </tr>
  <tr>
  <td>Minimum Working Hour</td>
    <td>
    <div class="input-append">
  
  <input class="min_working_hour span4" id="prependedInput" type="text" placeholder="" name="min_working_hour"  value="<?=set_value('min_working_hour')?>">
  <span class="add-on">Hr.</span>
    </td>
      <td>
       <?= form_error('min_working_hour')?> 
      </td>
  </tr>
  <tr>
    <td>Per hour <small class="muted">(   per day / working hour )</small></td>
    <td><div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input class="per_hour span4" id="prependedInput" type="text" placeholder="" name="per_hour_salary"  value="<?=set_value('per_hour_salary')?>"  readonly="readonly"></td>
    <td class="text-error"> <?= form_error('per_hour_salary')?>   </td>
  </tr>
  <tr>
    <td>Paid Leave Allowed</td>
    <td><input type="text" class="span3" name="paid_leave" value="<?=set_value('paid_leave')?>"/></td>
    <td class="text-error"><?= form_error('paid_leave')?></td>
  </tr>
  <tr>
    <td>Paid Leave / month</td>
    <td><input type="text" class="span3"  name="per_month_leave" value="<?=set_value('per_month_leave')?>"/></td>
    <td class="text-error"><?= form_error('per_month_leave')?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" value="Create Salary" />
    <input type="reset" />
    </td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>

<script type="text/javascript">
$(".salary").change(function() {
	var salary = $(".salary").val();
	
	var per_day = salary / 25;
	var per_hour = 
	$('.per_day').val(per_day);	
	
	if($('.min_working_hour').val())
	{
	$('.per_hour').val($('.per_day').val() / $('.min_working_hour').val())
	}
	
	})
	
/*$(".salary").focus( function () {	
	$('.per_day').val(""); 
	})	*/
	
	$('.min_working_hour').change(function () {
		
		$('.per_hour').val($(".per_day").val() / $('.min_working_hour').val())	
		
		})
		
		$('.per_day').change(function () {
			
			
			})
	
</script>